//============================================================================
// Copyright (C) 2012-2013 Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
#include "VxDualInetAddress.h"

//============================================================================
VxDualInetAddress::VxDualInetAddress()
{
}

//============================================================================
void VxDualInetAddress::addAddress( VxInetAddress& addr )
{
	m_aoAddresses.push_back(addr);
}

//============================================================================
bool VxDualInetAddress::haveIPv6Address( void )
{
	std::vector<VxInetAddress>::iterator oIter;
	for( oIter = m_aoAddresses.begin(); oIter != m_aoAddresses.end(); ++oIter )
	{
		if((*oIter).isIPv6())
		{
			return true;
		}
	}
	return false;
}

//============================================================================
bool VxDualInetAddress::haveIPv4Address( void )
{
	std::vector<VxInetAddress>::iterator oIter;
	for( oIter = m_aoAddresses.begin(); oIter != m_aoAddresses.end(); ++oIter )
	{
		if((*oIter).isIPv4())
		{
			return true;
		}
	}
	return false;
}

//============================================================================
VxInetAddress VxDualInetAddress::getIPv6Address()
{
	std::vector<VxInetAddress>::iterator oIter;
	for( oIter = m_aoAddresses.begin(); oIter != m_aoAddresses.end(); ++oIter )
	{
		if((*oIter).isIPv6())
		{
			return (*oIter);
		}
	}
	return VxInetAddress();
}

//============================================================================
VxInetAddress VxDualInetAddress::getIPv4Address()
{
	std::vector<VxInetAddress>::iterator oIter;
	for( oIter = m_aoAddresses.begin(); oIter != m_aoAddresses.end(); ++oIter )
	{
		if((*oIter).isIPv4())
		{
			return (*oIter);
		}
	}
	return VxInetAddress();
}
